﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="EditDocument.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.EditDocument" ValidateRequest="false"%>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript" src="../../Content/javascript/jquery.wysiwyg.js"></script>
    <script type="text/javascript">
       $(document).ready(function(){

        $("#Body").wysiwyg({
            controls: {
                underline : {visible : true},
                insertOrderedList : { visible : true },
                insertUnorderedList : { visible : true },
                undo : { visible : true },
                redo : { visible : true },
                cut : { visible : true },
                copy : { visible : true },
                paste : { visible : true },
                h1 : { visible : false },
                h2 : { visible : false },
                h3 : { visible : false }
                }
        });
        
        $('#Title').focus();
        
        $("#frmNewDocument").validate({
           rules: {
             Title: "required"
           },
           errorLabelContainer:"#frmDocumentErr",
           messages: {
             Title: "Please enter a title."
           }
        });
        
      });
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="StylePlaceHolder" runat="server">
    <link href="../../Content/jquery.wysiwyg.css" rel="stylesheet" type="text/css"  />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% LBRDataContext dc = new LBRDataContext();  %>
    <% NewsItem n = dc.GetNewsItem(int.Parse(ViewData["NewsItemId"].ToString()));
       if (n == null) n = new NewsItem();
       object vals = new { newsItemId = n.NewsItemId };
    %>
    <div class="contentDiv" style="margin-left:2%; margin-top:20px">
        <form method="post" id="frmNewDocument" enctype="multipart/form-data" action="<%=  Url.Action("SaveOrUpdateNewsItem", "Admin", vals ) %>" >
            <fieldset id="fldRegister" style="width:700px;display:block;">
                <legend><%= n.NewsItemId == 0 ? "New" : "Edit"%> News Item</legend>
                <div><label class="label" for="Title">Title:&nbsp;</label></div>
                <div><%= Html.TextBox("Title", n.Title)%><%=Html.CheckBox("Featured", n.Featured.GetValueOrDefault()) %><label>Is Featured</label></div>
                <div><label class="label" for="Description">Body:&nbsp;</label></div>
                <%= Html.TextArea("Body", n.Body, new { style="width:700px; height:400px;"})%>
                <div id="frmDocumentErr" class="ValidateErrorContainer"></div>
            </fieldset>
            <div style="display:inline">
                <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
                <button onclick = "window.history.back(); return false;">Cancel</button>
            </div>
        </form>
    </div>
</asp:Content>
